<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
<script>
    // 获取min 到 max 之间的数   (1,100) 只能取[1,99]的数
    function myRandom(max, min) {
        return Math.floor(Math.random() * (max - min) + min)
    }

    // 随机 颜色
    function randomColor() {
        let r = myRandom(0, 256)
        let g = myRandom(0, 256)
        let b = myRandom(0, 256)
        // 用模板字符串(ES6) 代替原来的 + 拼接
        let result = `rgb(${r},${g},${b})`
        return result
    }

    let color = randomColor()
    console.log(color)

    document.body.style.backgroundColor = color
</script>
</body>

</html>
